package org.example.java.socket.TCP;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server3 {

    public static void main(String[] args) throws Exception {
        ServerSocket server = new ServerSocket(6666);
        System.out.println("=====服务器运行，等待客户连接=====");
        Socket client = server.accept();
        DataInputStream dis = new DataInputStream(client.getInputStream());
        System.out.println(dis.readUTF());

        DataOutputStream dos = new DataOutputStream(client.getOutputStream());
        Thread.sleep(2000);
        dos.writeUTF("hello too!");
        dos.flush();
        dis.close();
        dos.close();
        client.close();

    }

}
